package com.vint.mi;


/**
 * 1.done
 * 2.
 *  判断四个点能否组成正方形
 */
public class Mi68 {

    public static String solution(String line){
        String[] lines = line.split(";");
        String[] s1 = lines[0].split(",");
        Point p1 = new Point(Double.parseDouble(s1[0]),Double.parseDouble(s1[1]));
        String[] s2 = lines[1].split(",");
        Point p2 = new Point(Double.parseDouble(s2[0]),Double.parseDouble(s2[1]));
        String[] s3 = lines[2].split(",");
        Point p3 = new Point(Double.parseDouble(s3[0]),Double.parseDouble(s3[1]));
        String[] s4 = lines[3].split(",");
        Point p4 = new Point(Double.parseDouble(s4[0]),Double.parseDouble(s4[1]));
        if(isSqure(p1,p2,p3,p4))
            return "1";
        else
            return "0";
    }

    public static double XX = 0.000000001;
    public static boolean isSqure(Point p1, Point p2, Point p3, Point p4){
        double p1p2 = distanceSqr(p1,p2);
        double p1p3 = distanceSqr(p1,p3);
        double p2p3 = distanceSqr(p2,p3);
        if(Math.abs(p1p2-p1p3)<=XX&&Math.abs(p1p2*2-p2p3)<=XX){
            if(Math.abs(distanceSqr(p2,p4)-distanceSqr(p3,p4))<=XX
                    &&Math.abs(distanceSqr(p1,p4)-distanceSqr(p2,p3))<=XX)
            return true;
        }
        if(Math.abs(p1p2-p2p3)<=XX&&Math.abs(p1p2*2-p1p3)<=XX){
            if(Math.abs(distanceSqr(p1,p4)-distanceSqr(p3,p4))<=XX
                    &&Math.abs(distanceSqr(p2,p4)-distanceSqr(p1,p3))<=XX)
            return true;
        }
        if(Math.abs(p1p3-p2p3)<=XX&&Math.abs(p1p3*2-p1p2)<=XX){
            if(Math.abs(distanceSqr(p1,p4)-distanceSqr(p2,p4))<=XX
                    &&Math.abs(distanceSqr(p3,p4)-distanceSqr(p1,p2))<=XX)
            return true;
        }
        return false;
    }

    private static double distanceSqr(Point p1, Point p2){
        return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y);
    }
    static class Point{
        double x;
        double y;
        Point(double x1, double y1){
            x = x1;
            y = y1;
        }
    }
    public static void main(String[] args) {
        //System.out.println(solution("0,0;1,1;1,0;0,1"));
        System.out.println(solution("83,80;180,80;180,177;83,177"));
    }
}
